/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.javlov.vf;

import net.javlov.State;

/**
 * Doesn't have to be a table, as long as it explicitly stores values; the
 * difference and additional functionality of this interface w.r.t. the {@link ValueFunction}
 * is that a ValueTable returns Values; this is useful for
 * maintaining pointers to values.
 * 
 * Another functionality w.r.t. the ValueFunction is that ValueTables can have an
 * initializer function associated with them; this function provides initial values
 * for newly encountered states.
 * 
 * @author matthijs
 *
 */
public interface ValueTable<T> extends ValueFunction<T> {
	
	/**
	 * Returns the value of the state s; returns an initial value if the state is not
	 * currently known.
	 * 
	 * @param s the state for which to get the value
	 * @return value of s if it is known, or an initial value if it is not
	 */
	Value get(State<? extends T> s);
	
	/**
	 * Sets the Value of state s
	 * 
	 * @param s the state
	 * @param val the value
	 */
	void set(State<? extends T> s, Value val);
	
	/**
	 * Sets an initializer. Any new state will be initialized according to the passed
	 * function's {@link #getValue(State)} method. If no initializer is set, values of
	 * new states will be initialized to 0.
	 * 
	 * @param vf the initializer function
	 */
	void setInitializer(ValueFunction<T> vf);
	
	/**
	 * 
	 * @return the size of the table (how many state-value pairs it contains)
	 */
	int size();
}
